package com.freemyleft.left.left_app.mian.index.work.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.freemyleft.left.zapp.delegates.LeftDelegate;

import java.util.ArrayList;
import java.util.List;

public class WorkPageAdapter extends FragmentStatePagerAdapter {
    private List<String> list_Title;
    private ArrayList<LeftDelegate> delegates;

    public WorkPageAdapter(FragmentManager fm, List<String> list_Title, ArrayList<LeftDelegate> delegates) {
        super(fm);
        this.list_Title = list_Title;
        this.delegates = delegates;
    }

    public WorkPageAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        return delegates.get(position);
    }

    @Override
    public int getCount() {
        return list_Title.size();
    }

    //此方法用来显示tab上的名字
    @Override
    public CharSequence getPageTitle(int position) {

        return list_Title.get(position % list_Title.size());
    }
}
